<!DOCTYPE html>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="/common/commonCss.jsp"/>
<link href='${basePath}commonCss/css/fullcalendar.css' rel='stylesheet' />
<link href='${basePath}commonCss/css/fullcalendar.print.css' rel='stylesheet' media='print' />
<link rel="stylesheet"   type="text/css" href="${basePath}commonCss/css/baseDatePicker/ui.all.css" />
 <script  type="text/javascript" src="${basePath}commonJs/jquery.min.js"></script>
<script  type="text/javascript" src="${basePath}commonJs/jquery.easyui.min.js"></script>
<script type="text/javascript" src='${basePath}commonJs/lib/moment.min.js'></script>
<script type="text/javascript" src="${basePath}commonJs/jquery.min.js"></script>
<script type="text/javascript" src='${basePath}commonJs/lib/jquery-ui.custom.min.js'></script>
<script type="text/javascript" src='${basePath}commonJs/fullcalendar_guanli.js'></script>
<script type="text/javascript" src='${basePath}commonJs/lang-all.js'></script>

<script type="text/javascript" src='${basePath}commonJs/jquery.fancybox-1.3.1.pack.js'></script>
<script type="text/javascript" src="${basePath}commonJs/ui/ui.core.js"></script>
<script type="text/javascript" src="${basePath}commonJs/ui/ui.datepicker.js"></script>
<script type="text/javascript" src="${basePath}commonJs/ui/ui.datepicker-zh-CN.js"></script>
<script type="text/javascript" src="${basePath}commonJs/jquery.form.min.js"></script>
<script type="text/javascript" src="${basePath}commonJs/jt_normal.js"></script>
<script type="text/javascript" src="${basePath}commonJs/management_tuan.js"></script>
<script type="text/javascript" src="${basePath}commonJs/calendar.js"></script>
<script type="text/javascript">
var roomArray=null;
var fangArray=[];
var fanglength =0;
var baseLocalPath='${basePath }';
//var jiawu=new Array("0wufang-","1tangguo-","2tuhua-","3qixiu-","4gongneng-");//声明 房屋类型 数组 4657
$(document).ready(function() {
	getparRoomList();
	  roomArray= new   Array();    
	<c:forEach items="${listRoom}" var="parRoom" varStatus="status">
	  roomArray['${status.index}']='${parRoom.roomName}-';
	</c:forEach>
	  fanglength =roomArray.length;
	var customerDate ='${dateNow}';
	$('#calendar').fullCalendar('destroy');
	//renderCalendar(customerDate);
	renderCalendar(customerDate);
});

function getparRoomList(){
	 var url ='${basePath }parreserve/findParReserveRooMList.shtml';
	$.ajax({
		   url: url,
		   type: 'POST',
		   data:"",//序列化表单里所有的内容
		      async:false, 
		   success:function(data){
				if (data != null) {
					var jsonarray ;
					var parStatus=new Array("未预付","自动取消","取消","待确认","已确认","进行中","完成","删除");
					fangArray=[];
					 for(var o in data){ 
						 if(o=="gblparResRoomMap"){
							 jsonarray=data[o];
							// var obj = str.parseJSON(); start: '2014-06-12T10:00:00',
					//end: '2014-06-12T12:00:00'
							
							 for (var k = 0; k < jsonarray.length; k++){
								 fangArray.push();
								 var jsonobj = jsonarray[k];
								 var statusInt=jsonobj["resStatus"];
								 var parStatusName=parStatus[statusInt-1];
								 var subject=jsonobj["subject"];
								 var conName=jsonobj["conName"];
								 if(conName==null){
									 conName ="";
								 }
								 if(subject==null){
									 subject ="";
								 }
								 if(subject.length>12){
									 subject =subject.substring(0,12)+"...";
								 }
								 if(conName.length>12){
									 conName =conName.substring(0,12)+"...";
								 }
								 var fangid=jsonobj["roomName"]+"-"+jsonobj["roomId"]+"@"+jsonobj["lockFlag"];
								 var partitle=jsonobj["roomName"]+"-"+parStatusName+"\n"+subject+"\n"+conName+" "+jsonobj["conMobile"];
								 var resTimeS=jsonobj["resTimeS"];
								 var resTimeE=jsonobj["resTimeE"];
								 var parStart=jsonobj["presDay"]+"T"+resTimeS;
								 var parEnd=jsonobj["presDay"]+"T"+resTimeE;
								 var grpFlag=jsonobj["grpFlag"];
								 var pkParresId =jsonobj["pkParresId"];
								 var detailUrl;
								 var grpName="";
								 if(grpFlag=="0"){
									 grpName="派对";
								 }else{
									 grpName="团体";
								 }
								 
								 if('${type}'==1){//进场
									 if(statusInt!="5" && statusInt!="6"){
										 detailUrl='javascript:alert("已确认的'+grpName+'才能进场!");';//进行中的也可以进
									 }else{
										 //派对预约时间
										 var resTimeStart=jsonobj["resTimeStart"];
								 		 var resTimeEnd=jsonobj["resTimeEnd"];
								 		 
										 var myDate = new Date();
										 var nowHours = myDate.getHours();       //获取当前小时数(0-23)
										 var nowMinutes = myDate.getMinutes();     //获取当前分钟数(0-59)
										 
										 var nowHoursAddHalf = myDate.getHours();
										 var nowMinutesAddHalf = parseInt(nowMinutes) + 30;
									        if (nowMinutesAddHalf>60)
									        {
									        	nowMinutesAddHalf -= 60;
									        	nowHoursAddHalf++;
									        }
										 if(null!=nowMinutes && parseInt(nowMinutes)<10){
											 nowMinutes="0"+nowMinutes;
										 }
										 if(null!=nowMinutesAddHalf && parseInt(nowMinutesAddHalf)<10){
											 nowMinutesAddHalf="0"+nowMinutesAddHalf;
										 }
										 var nowHM=nowHours+""+nowMinutes;
										 var nowHMAddHalf=nowHoursAddHalf+""+nowMinutesAddHalf;
										 if(null!=resTimeStart && resTimeStart!=""){
											 resTimeStart=parseInt(resTimeStart);
										 }else{
											 resTimeStart=0;
										 }
										 
										 if(null!=resTimeEnd && resTimeEnd!=""){
											 resTimeEnd=parseInt(resTimeEnd);
										 }else{
											 resTimeEnd=0;
										 }
										 
										 if(null!=nowHM && nowHM!=""){
											 nowHM=parseInt(nowHM);
										 }else{
											 nowHM=0;
										 }
										 if(null!=nowHMAddHalf && nowHMAddHalf!=""){
											 nowHMAddHalf=parseInt(nowHMAddHalf);
										 }else{
											 nowHMAddHalf=0;
										 }
										 //alert(nowHM+"-"+resTimeStart+"-"+resTimeEnd);
										 if(nowHMAddHalf<resTimeStart){
											 detailUrl='javascript:alert("只可提前30分钟进场!");';
										 }else if(nowHM>=resTimeEnd){
											 detailUrl='javascript:alert("派对已超时!");';
										 }else{
											 detailUrl='${basePath }parreserve/inManagementParReg.shtml?pkParresId='+pkParresId+'&grpFlag='+grpFlag+'&type=1';
										 }
									 }
								 }else{//出场 
									 if(statusInt!="6"){
										 detailUrl='javascript:alert("进行中的'+grpName+'才能出场!");';
									 }else{
										 detailUrl='${basePath }parreserve/outManagementParReg.shtml?pkParresId='+pkParresId+'&grpFlag='+grpFlag+'&type=2';
									 }
								 }
								 var wristColor=jsonobj["wristColor"];
								 var bgColor="";
								 switch(wristColor){
									case "1":
										bgColor="#FF0000";
									  	break;
									case "2":
										bgColor="#FFA500";
									  	break;
									case "3":
										bgColor="#FFFF00";
									  	break;
									case "4":
										bgColor="#7FFF00";
									  	break;
									case "5":
										bgColor="#0000FF";
									  	break;
									case "6":
										bgColor="#00FFFF";
									  	break;
									case "7":
										bgColor="#800080";
									  	break;
									case "8":
										bgColor="#000000";
									  	break;
								 }
								 var testJson = { "id": fangid, "title":partitle,"start":parStart,"end":parEnd,"url":detailUrl,"backgroundColor":bgColor};
								 fangArray.push(testJson);
							 }
							 
						 }
					 }
				}else{
					 $.messager.alert('提示','加载预约房间失败！','error');
				}
		   }
		  });
}
</script>
</head>
<body class="bg">

<div class="content m_auto ">
	<div class="content_l mt10">
    	<ul>
        	<shiro:hasPermission name="management/site/locPerManager.shtml?type=1">
				<li <c:if test="${type==1 }">class="content_hover"</c:if>><a href="${basePath}management/site/locPerManager.shtml?type=1"><i class="nav_icon_c"></i><br>入场管理</a></li>
			</shiro:hasPermission>
        	<shiro:hasPermission name="management/site/locPerManager.shtml?type=2">
            	<li <c:if test="${type==2 }">class="content_hover"</c:if>><a href="${basePath}management/site/locPerManager.shtml?type=2"><i class="nav_icon_i"></i><br>出场管理</a></li>
            </shiro:hasPermission>
            <shiro:hasPermission name="management/site/locPerMemer.shtml">
            	<li><a href="${basePath}management/site/locPerMemer.shtml"><i class="nav_icon_j"></i><br>场内人员</a></li>
            </shiro:hasPermission>
        </ul>
    </div>
    <div class="content_r mt10 tc">
    <div id='calendar' class="mt20"></div>
    </div>
</div>
</body>
</html>
